﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Director : MonoBehaviour
{
    // Start is called before the first frame update
    // 移动速度
    private float _time = 1;
    // 一次产生几个食物
    private int _foodsNum = 10;
    public GameObject ScreenMain;
    public GameObject Food;
    public GameObject Snake;
    private ScreenMain screenMain;
    private Food food;
    private Snake snake;
    void Start()
    {
        // 初始化屏幕
        screenMain = ScreenMain.GetComponent<ScreenMain>();
        food = Food.GetComponent<Food>();
        snake = Snake.GetComponent<Snake>();

        screenMain.init();
        InvokeRepeating("gaming", 0, _time);
    }
    void gaming() {
        
        // snake.arrow = Input.anyKeyDown;
        screenMain.snakePoint = snake.snakePoint;
        screenMain.foodsPoint = food.creatFoods(snake.snakePoint, _foodsNum);
        screenMain.refScreenMain();
        snake.move();
    }
    // Update is called once per frame
    void Update()
    {
        // if (Input.anyKeyDown) {

        //     Debug.Log(Event.current.keyCode);
        //     snake.arrow = Event.current.keyCode;
        // }
        // snake.arrow = KeyCode.S;
         if (Input.anyKeyDown)  
        {  
            Event e = Event.current;  
            if (e.isKey)  
            {  
                Debug.Log(e);  
            }  
        }  
    }
}
